package model.student;

import java.sql.ResultSet;
import java.util.ArrayList;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import vo.TimeTableVo;

import model.admin.TimeTableMo;
import myutil.Connect;

public class StudentTimeTableMo {
	
	public ArrayList<TimeTableVo> getStudentTimeTable(){
		ArrayList<TimeTableVo> vo = new ArrayList<TimeTableVo>();
		HttpSession session = ServletActionContext.getRequest().getSession();
		String email_id = session.getAttribute("username").toString();
		String query="select batch_id from student_batch where student_id in(select student_id from student_details where email_id='"+email_id+"')";
		System.out.println(query);
		Connect c= new Connect();
		String query1="";
		int batch=0;
		try {
			ResultSet rs= c.getResult(query);
			while(rs.next()){
				batch=rs.getInt(1);
			}
			query1="select * from time_table where batch_id="+batch;
			System.out.println(query1);
			rs= c.getResult(query1);
			while(rs.next()){
				TimeTableVo time = new TimeTableVo();
				time.setAttachment_id(rs.getInt("time_table_id"));
				time.setDocument_name(rs.getString("document_name"));
				time.setSubject(rs.getString("subject"));
				time.setUploader(rs.getString("uploader"));
				time.setUpload_time(rs.getString("upload_time"));
				time.setBatch_id(batch);
				vo.add(time);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return vo;
	}

}
